import { get, post } from '../utils/http';
export const phoneAPI = {
  // 获取全球国家区号
  getSmsCodeList: async (): Promise<Phone.RegionCode> => {
    try {
      const res = await get<Phone.RegionCode>('/turing-user-center/v1/sms/phone-codes');
      return res.data;
    } catch (error) {
      console.log(error);
      throw new Error('Obtaining phone code list failed');
    }
  },
  // 发送短信验证码
  sendSmsCode: async (phoneCode: string, phoneNumber: string): Promise<void> => {
    try {
      await post('/turing-user-center/v1/sms/code', {
        phoneCode,
        phoneNumber,
        // 业务类型，用于登录
        type: 1,
      });
    } catch (error) {
      console.log(error);
      throw new Error('Sending SMS code failed');
    }
  },
};
